package sgi.client;

import java.awt.BorderLayout;
import javax.swing.JOptionPane;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import sgi.user.User;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;

public class SGIUserAccountMenuUI extends JFrame {

	private JPanel contentPane;
	private SGIUserAccountMenuController menu;
	
	public SGIUserAccountMenuUI(User user) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 406, 284);
		contentPane = new JPanel();
		contentPane.setLayout(null);
		setContentPane(contentPane);
		setTitle("SGI-"+user.getUsername());
		
	
		JButton btnSearchArchive = new JButton("Search Archive");
		btnSearchArchive.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SGISearchArchiveController.create();
				SGIUserAccountMenuController.terminate();
			}
		});
		btnSearchArchive.setBounds(37, 30, 133, 23);
		contentPane.add(btnSearchArchive);
		
		JButton btnInteractiveMap = new JButton("Interactive Map");
		btnInteractiveMap.setBounds(219, 30, 142, 23);
		contentPane.add(btnInteractiveMap);
		
		JButton btnPurchasedImages = new JButton("Purchased Images");
		btnPurchasedImages.setBounds(37, 81, 133, 23);
		contentPane.add(btnPurchasedImages);
		
		JButton btnPurchaseSubscription = new JButton("Purchase Subscription");
		btnPurchaseSubscription.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnPurchaseSubscription.setBounds(219, 81, 142, 23);
		contentPane.add(btnPurchaseSubscription);
		
		JButton btnCompaint = new JButton("File a complaint");
		btnCompaint.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					SGIComplaintController.create(SGIUserAccountMenuController.create(null).getUser());
					SGIUserAccountMenuController.terminate();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnCompaint.setBounds(37, 134, 133, 23);
		contentPane.add(btnCompaint);
		
		JButton btnAccountInfo = new JButton("Account Info");
		btnAccountInfo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnAccountInfo.setBounds(219, 134, 142, 23);
		contentPane.add(btnAccountInfo);
		
		JButton btnLogoff = new JButton("Logoff");
		btnLogoff.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)  {
				try {
					SGILoginController login = SGILoginController.createLogin();
					login.logoff(menu.getUser());
				} catch (IOException e1) {e1.printStackTrace();}
			}
		});
		btnLogoff.setBounds(272, 197, 89, 23);
		contentPane.add(btnLogoff);
	}

	public SGIUserAccountMenuController getMenu() {
		return menu;
	}

	public void setMenu(SGIUserAccountMenuController menu) {
		this.menu = menu;
	}

}
